<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;


/**
 * @property int $id
 * @property string $parent_id
 * @property string $path
 * @property string $component
 * @property string $title
 * @property int $sort
 * @property string $icon
 * @property string $type
 * @property string $create_time
 * @property string $update_time
 * @property string $redirect
 * @property string $name
 * @property int $hidden
 * @property string $perm
 * @property int $is_external
 */
class Menu extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'menu';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'parent_id', 'path', 'component', 'title', 'sort', 'icon', 'type', 'create_time', 'update_time', 'redirect', 'name', 'hidden', 'perm', 'is_external'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'sort' => 'integer', 'hidden' => 'integer', 'is_external' => 'integer'];

    public function children()
    {
        return $this->hasMany(Menu::class, 'parent_id', 'id');
    }
}
